// Reservation.java - 预约记录实体类
package com.library.entity;

import java.time.LocalDate;

public class Reservation {
    private String reservationId;
    private String readerId;
    private String bookIsbn;
    private LocalDate reserveDate;
    private LocalDate expireDate;
    private ReservationStatus status;

    public enum ReservationStatus {
        ACTIVE, FULFILLED, EXPIRED, CANCELLED
    }

    public Reservation(String reservationId, String readerId, String bookIsbn) {
        this.reservationId = reservationId;
        this.readerId = readerId;
        this.bookIsbn = bookIsbn;
        this.reserveDate = LocalDate.now();
        this.expireDate = reserveDate.plusDays(3); // 预约保留3天
        this.status = ReservationStatus.ACTIVE;
    }

    // Getter和Setter方法
    public String getReservationId() { return reservationId; }
    public void setReservationId(String reservationId) { this.reservationId = reservationId; }

    public String getReaderId() { return readerId; }
    public void setReaderId(String readerId) { this.readerId = readerId; }

    public String getBookIsbn() { return bookIsbn; }
    public void setBookIsbn(String bookIsbn) { this.bookIsbn = bookIsbn; }

    public LocalDate getReserveDate() { return reserveDate; }
    public void setReserveDate(LocalDate reserveDate) { this.reserveDate = reserveDate; }

    public LocalDate getExpireDate() { return expireDate; }
    public void setExpireDate(LocalDate expireDate) { this.expireDate = expireDate; }

    public ReservationStatus getStatus() { return status; }
    public void setStatus(ReservationStatus status) { this.status = status; }

    public boolean isExpired() {
        return LocalDate.now().isAfter(expireDate) && status == ReservationStatus.ACTIVE;
    }
}
